package ru.spb.osll.myfit.util.logger;


public class MyFitLogger {
/*
  private static LinkedList<FileAppender> appendersToClose = new LinkedList<FileAppender>();


  private static final String DEFAULT_PATTERN = "%d{ABSOLUTE} %5p  %C{1}:%L - %m%n";  
  public static Logger getLogger(Class< ? > clazz) {
    String loggerName = MyFitProperties.getProperty(MyFitProperties.MYFIT_LOGGER_CATEGORY_NAME);
    String filename = MyFitProperties.getProperty(MyFitProperties.LOGGER_OUTPUT_FILE);
    
    if(loggerName != null && filename != null){
      return createLogger(loggerName, filename);
    } else {
      System.err.println("did not find logger file name and test dir");
      return Logger.getLogger(clazz);
    }
  }

  private static Logger createLogger(String loggerName, String logFile) {
    Logger log = Logger.getLogger(loggerName);
    Enumeration<?> allAppenders = log.getAllAppenders();
    if (!allAppenders.hasMoreElements()) {
      FileAppender appender;
      try {
        String patternLayout = MyFitProperties.getProperty("logger.pattern.layout", DEFAULT_PATTERN);
        appender = new FileAppender(new PatternLayout(
            patternLayout), logFile);
        log.addAppender(appender);
        appendersToClose.add(appender);
      } catch (Exception e) {
    	  e.printStackTrace();
      }
      log.setAdditivity(false);
      String level = MyFitProperties.getProperty("logger.level", "info");
      log.setLevel(Level.toLevel(level));
    }
    return log;
  }

  public static void closeAppenders() {
    for (FileAppender appender : appendersToClose) {
      appender.close();
    }
  }*/
}
